<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>订单详情表列表</title>
</head>
<body>
<form>
       输入关键字：<input id="keyword" name="keyword"/>
    <input type="button" value="查询" id="cxBtn"/>
</form>
<table width="100%" border="1">
    <caption>订单详情表列表</caption>
    <thead>
    <tr style="font-weight:bold;background:#a0a0ff">
            <td>订单详情表ID</td>
            <td>订单表ID</td>
            <td>订单商品ID</td>
            <td>商品名称</td>
            <td>平均成本价格</td>
            <td>商品重量</td>
            <td>入库时间</td>
            <td>最后修改时间</td>
            <td>其他</td>
            <td>其他</td>
        <td>操作</td>
    </tr>
    </thead>
    <tbody>
    </tbody>
</table>
<script src="/js/jquery-1.12.4.js"></script>
    <script>
    $(function(){
        fill("/orderdetail/findAll.json","");
        $("#cxBtn").click(function(){
            fill("/orderdetail/query.json",$("form").serialize());
        });
    });
    //填充数据
    function fill(url,data){
        $.getJSON(url,data,function(list){
            $("tbody").empty();
            for(var i in list){
                var detail = list[i];
                var str="<tr>";
                str+="<td>"+detail.orderDetailId+"</td><td>"+detail.orderId+"</td><td>"+detail.productId+"</td><td>"+detail.productName+"</td><td>"+detail.averageCost+"</td><td>"+detail.weight+"</td><td>"+detail.inData+"</td><td>"+detail.modifiedTime+"</td><td>"+detail.other1+"</td><td>"+detail.other2+"</td>";
                str+="<td><a href='javascript:view("+detail.orderDetailId+")'>查看</a>&nbsp;&nbsp;";
                str+="<a href='javascript:update("+detail.orderDetailId+")'>修改</a>&nbsp;&nbsp;";
                str+="<a href='javascript:del("+detail.orderDetailId+")'>删除</a>";
                str+="</td></tr>";
                $("tbody").append(str);
            }
        });
    }
    //查看明细
    function view(orderDetailId){
        location.href="/admin/orderdetail/detail.html?orderDetailId="+orderDetailId;
    }
    //更新
    function update(orderDetailId){
        location.href="/admin/orderdetail/update.html?orderDetailId="+orderDetailId;
    }
    //删除
    function del(id){
        $.post("/orderdetail/delete.json",
               {orderDetailId:orderDetailId},
               function(result){
                   if(result.flag==true){
                        fill("/orderdetail/query.json",$("form").serialize());
                        alert("删除成功");
                   }else{
                        alert("删除失败");
                   }
               },"json");
    }
</script>
</body>
</html>